<template>
  <div class="tender-writing-container">
    <!-- 顶部横幅 -->
    <div class="top-banner">
      <div class="banner-left">
        <div class="banner-icon-wrapper">
          <div class="banner-icon">
            <el-icon><User /></el-icon>
            </div>
          </div>
        <div class="banner-content">
          <h3>专家团队支持</h3>
          <p>专业团队为您解决标书相关问题，提供一对一咨询服务</p>
          <div class="banner-features">
            <span class="feature-item">✓ 一对一咨询</span>
            <span class="feature-item">✓ 专业解答</span>
          </div>
        </div>
      </div>
      <div class="banner-divider"></div>
      <div class="banner-right">
        <div class="banner-content">
          <h3>智能生成标书</h3>
          <p>基于AI技术，快速生成专业标书，提升工作效率</p>
          <div class="banner-features">
            <span class="feature-item">✓ AI驱动</span>
            <span class="feature-item">✓ 快速生成</span>
          </div>
        </div>
        <el-button type="primary" size="small" class="suggest-btn">
          <el-icon><EditPen /></el-icon>
          建议
        </el-button>
      </div>
    </div>

    <!-- 主标题区域 -->
    <div class="main-title-section">
      <div class="title-content">
        <h1>最强大的标书助手</h1>
        <p class="subtitle">让标书写作变得简单高效，专业团队为您保驾护航</p>
        <div class="title-features">
          <span class="feature-tag">AI驱动</span>
          <span class="feature-tag">专业团队</span>
          <span class="feature-tag">高效生成</span>
        </div>
      </div>
    </div>

    <!-- 动态消息提醒 -->
    <div class="message-ticker">
      <div class="ticker-icon">
        <el-icon><Clock /></el-icon>
      </div>
            <div class="ticker-content">
        <transition name="fade-slide" mode="out-in">
          <div :key="currentMessageIndex" class="ticker-message">
            <span class="message-text">{{ currentMessage.text }}</span>
            <span class="message-time">{{ currentMessage.time }}</span>
            </div>
        </transition>
          </div>
        </div>

    <!-- 功能卡片 -->
    <div class="feature-cards">
      <div 
            v-for="(card, index) in featureCards"
            :key="index"
            class="feature-card"
        :class="{ 'disabled': card.disabled }"
        @click="card.disabled ? null : handleCardClick(card)"
      >
        <div class="card-icon" :style="{ background: card.iconBg }">
          <el-icon><component :is="card.icon" /></el-icon>
        </div>
            <div class="card-content">
          <h3>{{ card.title }}</h3>
          <p>{{ card.description }}</p>
          <div class="card-footer">
            <span v-if="card.disabled" class="disabled-tag">暂未开放</span>
            <span v-else class="read-more">查看详情 <el-icon><ArrowRight /></el-icon></span>
              </div>
              </div>
            </div>
        </div>

    <!-- 常见问题 -->
        <div class="faq-section">
          <h2 class="section-title">常见问题</h2>
          <div class="faq-cards">
            <div 
          v-for="(faq, index) in faqItems" 
              :key="index" 
              class="faq-card" 
          :class="{ 'disabled': faq.disabled }"
          @click="faq.disabled ? null : navigateToFaqDetail(faq)"
            >
          <div class="faq-icon" :style="{ background: faq.iconBg }">
            <el-icon><component :is="faq.icon" /></el-icon>
                </div>
          <div class="faq-content">
            <h4>{{ faq.question }}</h4>
            <div class="faq-footer">
              <span v-if="faq.disabled" class="disabled-tag">暂未开放</span>
              <span v-else class="read-more">查看详情</span>
                  <el-icon><ArrowRight /></el-icon>
                </div>
              </div>
            </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
import { EditPen, TopRight, Document, ArrowRight, User, Clock } from '@element-plus/icons-vue'

const router = useRouter()

// 功能卡片数据
const featureCards = ref([
  {
    title: '按招标要求写',
    description: '精准响应评分点，轻松完成千页标书',
    icon: 'EditPen',
    iconBg: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
    disabled: false
  },
  {
    title: '编写专项章节',
    description: '精细编写单一标书章节，提升内容质量',
    icon: 'TopRight',
    iconBg: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
    disabled: true
  },
  {
    title: '按标书目录写',
    description: '上传章节目录，AI帮你写正文',
    icon: 'Document',
    iconBg: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)',
    disabled: true
  }
])

// 常见问题数据
const faqItems = ref([
  {
    question: '如何新建标书？',
    icon: 'Document',
    iconBg: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
    disabled: false
  },
  {
    question: '标书生成后还能修改吗？',
    icon: 'Document',
    iconBg: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
    disabled: true
  },
  {
    question: '如何提高我的标书中标率？',
    icon: 'TopRight',
    iconBg: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)',
    disabled: true
  },
  {
    question: '系统支持哪些类型的标书？',
    icon: 'Document',
    iconBg: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)',
    disabled: true
  }
])

// 动态消息数据
const messages = ref([
  { text: '钱七30分钟前使用了智能生成功能', time: '刚刚' },
  { text: '张三1小时前完成了标书编写', time: '1小时前' },
  { text: '李四2小时前使用了专项章节功能', time: '2小时前' },
  { text: '王五3小时前提交了标书审核', time: '3小时前' },
  { text: '赵六4小时前导入了招标文件', time: '4小时前' }
])

const currentMessageIndex = ref(0)
let messageTimer: NodeJS.Timeout | null = null

// 计算属性
const currentMessage = computed(() => messages.value[currentMessageIndex.value] || { text: '', time: '' })

// 方法
const handleCardClick = (card: any) => {
  if (card.disabled) return
  
  console.log('点击功能卡片:', card.title)
  
  // 根据卡片标题进行跳转
  switch (card.title) {
    case '按招标要求写':
      router.push('/dashboard/addTender')
      break
    case '编写专项章节':
      // 暂时跳转到占位页面
      router.push('/dashboard/chapterGen')
      break
    case '按标书目录写':
      // 暂时跳转到占位页面
      router.push('/dashboard/directoryGen')
      break
    default:
      console.log('未知的功能卡片:', card.title)
  }
}

const navigateToFaqDetail = (faq: any) => {
  if (faq.disabled) return
  
  console.log('查看FAQ详情:', faq.question)
  
  // 根据问题类型进行跳转
  switch (faq.question) {
    case '如何新建标书？':
      router.push('/dashboard/addTender')
      break
    case '标书生成后还能修改吗？':
      // 暂时跳转到占位页面
      router.push('/dashboard/editTender')
      break
    case '如何提高我的标书中标率？':
      // 暂时跳转到占位页面
      router.push('/dashboard/successRate')
      break
    case '系统支持哪些类型的标书？':
      // 暂时跳转到占位页面
      router.push('/dashboard/supportedTypes')
      break
    default:
      console.log('未知的FAQ问题:', faq.question)
  }
}

const switchToNextMessage = () => {
  currentMessageIndex.value = (currentMessageIndex.value + 1) % messages.value.length
}

// 生命周期
onMounted(() => {
  messageTimer = setInterval(switchToNextMessage, 3000)
})

onBeforeUnmount(() => {
  if (messageTimer) {
    clearInterval(messageTimer)
  }
})
</script>

<style lang="scss" scoped>
.tender-writing-container {
  background: linear-gradient(135deg, #f8fafc 0%, #e0f2fe 100%);
  color: var(--ai-text-primary);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  overflow: visible;
  min-height: 100vh;
}

/* 顶部横幅 */
.top-banner {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
  border: 1px solid var(--ai-border-light);
  border-radius: var(--ai-radius-xl);
  padding: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  box-shadow: var(--ai-shadow-lg);
  flex-shrink: 0;
  backdrop-filter: var(--ai-blur-md);
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--ai-gradient-primary);
    border-radius: var(--ai-radius-xl) var(--ai-radius-xl) 0 0;
  }
}

.banner-left,
.banner-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
}

.banner-right {
  justify-content: flex-end;
}

.banner-divider {
  width: 2px;
  height: 100px;
  background: linear-gradient(180deg, transparent 0%, var(--ai-border) 50%, transparent 100%);
  opacity: 0.6;
  flex-shrink: 0;
}

.banner-icon-wrapper {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--ai-radius-lg);
  background: var(--ai-gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--ai-shadow-md);
  
  &::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.2) 50%, transparent 70%);
    animation: shimmer 3s infinite;
  }
}

@keyframes shimmer {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.banner-icon {
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  border-radius: var(--ai-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
}

.banner-content h3 {
  font-size: 22px;
  font-weight: 700;
  color: var(--ai-text-primary);
  margin: 0 0 12px 0;
  background: var(--ai-gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.banner-content p {
  font-size: 15px;
  color: var(--ai-text-secondary);
  margin: 0;
  line-height: 1.6;
}

.banner-features {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.feature-item {
  background: var(--ai-bg-subtle);
  color: var(--ai-primary);
  padding: 6px 12px;
  border-radius: var(--ai-radius-md);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--ai-border-light);
  position: relative;
  
  &::before {
    content: '✓';
    margin-right: 6px;
    color: var(--ai-green);
    font-weight: bold;
  }
}

.suggest-btn {
  background: var(--ai-gradient-primary);
  border: none;
  padding: 10px 20px;
  font-size: 13px;
  height: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  color: white;
  border-radius: var(--ai-radius-md);
  cursor: pointer;
  transition: var(--ai-transition);
  font-weight: 600;
  box-shadow: var(--ai-shadow-md);
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: var(--ai-shadow-lg);
  }
}

/* 主标题区域 */
.main-title-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 24px;
  flex-shrink: 0;
}

.title-content {
  text-align: center;
}

.title-content h1 {
  font-size: 42px;
  font-weight: 800;
  color: var(--ai-text-primary);
  margin: 0 0 16px 0;
  background: var(--ai-gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 18px;
  color: var(--ai-text-secondary);
  margin: 0 0 20px 0;
  line-height: 1.6;
  max-width: 600px;
}

.title-features {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.feature-tag {
  background: var(--ai-bg-subtle);
  color: var(--ai-primary);
  padding: 8px 16px;
  border-radius: var(--ai-radius-md);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--ai-border-light);
  transition: var(--ai-transition);
  
  &:hover {
    background: var(--ai-primary);
    color: white;
    transform: translateY(-2px);
  }
}

/* 动态消息提醒 */
.message-ticker {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.8) 100%);
  border: 1px solid var(--ai-border-light);
  border-radius: var(--ai-radius-lg);
  padding: 18px 24px;
  margin: 0 auto;
  max-width: 500px;
  flex-shrink: 0;
  box-shadow: var(--ai-shadow-md);
  backdrop-filter: var(--ai-blur-sm);
  position: relative;

  &::before {
  content: '';
  position: absolute;
  left: 0;
    top: 0;
    bottom: 0;
  width: 4px;
    background: var(--ai-gradient-primary);
    border-radius: var(--ai-radius-lg) 0 0 var(--ai-radius-lg);
  }
}

.ticker-icon {
  color: var(--ai-primary);
  font-size: 20px;
  flex-shrink: 0;
}

.ticker-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ticker-message {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.message-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--ai-text-primary);
}

.message-time {
  font-size: 13px;
  color: var(--ai-text-secondary);
  background: var(--ai-bg-subtle);
  padding: 4px 8px;
  border-radius: var(--ai-radius-sm);
}

/* 功能卡片 */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.feature-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
  border: 1px solid var(--ai-border-light);
  border-radius: var(--ai-radius-xl);
  padding: 28px;
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
  backdrop-filter: var(--ai-blur-sm);

  &::before {
  content: '';
  position: absolute;
    top: 0;
  left: 0;
    right: 0;
    height: 3px;
    background: var(--ai-gradient-primary);
    transform: scaleX(0);
    transition: transform 0.3s ease;
  }
  
  &:hover:not(.disabled) {
    transform: translateY(-6px);
    box-shadow: var(--ai-shadow-xl);
    border-color: var(--ai-primary-light);
    
    &::before {
      transform: scaleX(1);
    }
  }
  
  &.disabled {
    opacity: 0.7;
    cursor: not-allowed;
    
    &:hover {
      transform: none;
      box-shadow: var(--ai-shadow-sm);
    }
  }
}

.card-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--ai-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  margin-bottom: 24px;
  background: var(--ai-gradient-primary);
  box-shadow: var(--ai-shadow-md);
}

.card-content h3 {
  font-size: 22px;
  font-weight: 700;
  color: var(--ai-text-primary);
  margin: 0 0 16px 0;
}

.card-content p {
  font-size: 15px;
  color: var(--ai-text-secondary);
  margin: 0;
  line-height: 1.6;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

.read-more {
  color: var(--ai-primary);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--ai-transition);
  
  &:hover {
    color: var(--ai-primary-light);
    transform: translateX(4px);
  }
}

.disabled-tag {
  display: inline-block;
  padding: 6px 12px;
  background: var(--ai-bg-overlay);
  color: var(--ai-text-tertiary);
  font-size: 13px;
  border-radius: var(--ai-radius-md);
  border: 1px solid var(--ai-border-light);
}

/* 常见问题 */
.faq-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
}

.section-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--ai-text-primary);
  margin: 0 0 24px 0;
  text-align: center;
  flex-shrink: 0;
  background: var(--ai-gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.faq-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  flex-shrink: 0;
}

.faq-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
  border: 1px solid var(--ai-border-light);
  border-radius: var(--ai-radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  height: 160px;
  display: flex;
  flex-direction: column;
  backdrop-filter: var(--ai-blur-sm);
  
  &:hover:not(.disabled) {
    transform: translateY(-4px);
    box-shadow: var(--ai-shadow-lg);
    border-color: var(--ai-border-accent);
  }
  
  &.disabled {
    opacity: 0.7;
    cursor: not-allowed;
    
    &:hover {
      transform: none;
      box-shadow: var(--ai-shadow-sm);
    }
  }
}

.faq-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--ai-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  margin-bottom: 20px;
  background: var(--ai-gradient-primary);
  box-shadow: var(--ai-shadow-md);
}

.faq-content h4 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ai-text-primary);
  margin: 0 0 12px 0;
}

.faq-content p {
  font-size: 15px;
  color: var(--ai-text-secondary);
  margin: 0;
  line-height: 1.6;
  flex: 1;
}

/* 动画 */
.fade-slide-enter-active,
.fade-slide-leave-active {
  transition: all 0.4s ease;
}

.fade-slide-enter-from {
  opacity: 0;
  transform: translateX(30px);
}

.fade-slide-leave-to {
  opacity: 0;
  transform: translateX(-30px);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .tender-writing-container {
    padding: 16px;
    gap: 20px;
  }
  
  .top-banner {
    flex-direction: column;
    gap: 20px;
    padding: 24px;
  }
  
  .banner-left,
  .banner-right {
    justify-content: center;
  }
  
  .title-content h1 {
    font-size: 32px;
  }
  
  .feature-cards {
    grid-template-columns: 1fr;
  }
  
  .faq-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .tender-writing-container {
    padding: 12px;
    gap: 16px;
  }
  
  .top-banner {
    padding: 20px;
  }
  
  .banner-icon-wrapper,
  .banner-icon {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
  
  .title-content h1 {
    font-size: 28px;
  }
  
  .feature-card {
    padding: 24px;
  }
  
  .faq-card {
    padding: 20px;
    height: 140px;
  }
}
</style>

